package homework4;

import java.util.Comparator;
import java.util.TreeSet;

/**
 * @classname:TreeSet
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/14 17:42
 * @version: 0.1
 * @since:1.8
 */
public class TreeSetDemo {
    public static void main(String[] args) {

        String str = "ABCDEFJHIGKMLNOPGRSTUVWXYZ";
        TreeSet<Student> set = new TreeSet<>(Comparator.comparing(Student::getScore));

        for (int i = 0; i < 20; i++) {
            Integer id = (int)(Math.random()*39+1);
            Integer score  =  (int)(Math.random()*90+10);
            StringBuilder sb = new StringBuilder();

            for (int i1 = 0; i1 < 4; i1++) {
                int  j = (int)(Math.random()*str.length());
                char name =str.charAt(j);
                sb.append(name);
            }
            System.out.println("学生姓名:"+sb+"\t学生id："+id+"\t学生分数:"+score);
            set.add(new Student(id,score,sb.toString()));
        }
        System.out.println("最低分:"+set.first());
        System.out.println("最高分:"+set.last());
    }
}
